﻿using Microsoft.Xna.Framework.Input;

namespace CymbergajTouch
{
    /// <summary>
    /// Class that registers keyboard entries.
    /// </summary>
    class KeyboardInput
    {
        KeyboardState lastKeyboardState;
        KeyboardState currentKeyboardState = new KeyboardState();

        /// <summary>
        /// Checks if new key was pressed.
        /// </summary>
        /// <param name="key">key</param>
        /// <returns>true if key was pressed</returns>
        public bool IsNewKeyPressed(Keys key)
        {
            return currentKeyboardState.IsKeyDown(key) && lastKeyboardState.IsKeyUp(key);
        }

        /// <summary>
        /// Updates keyboard state.
        /// </summary>
        public void Update()
        {
            lastKeyboardState = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();
        }
    }
}
